Private Declare Function mciSendCommand Lib "winmm.dll" Alias "mciSendCommandA" (ByVal wDeviceID As Long, ByVal uMessage As Long, ByVal dwParam1 As Long, ByRef dwParam2 As Any) As Long
Private Const MMSYSERR_NOERROR = 0
Private Const MCI_CLOSE = &H804
Private Const MCI_FORMAT_MSF = 2
Private Const MCI_OPEN = &H803
Private Const MCI_OPEN_ELEMENT = &H200&
Private Const MCI_OPEN_TYPE = &H2000&
Private Const MCI_SET = &H80D
Private Const MCI_SET_TIME_FORMAT = &H400&
Private Const MCI_STATUS_ITEM = &H100&
Private Const MCI_STATUS_LENGTH = &H1&
Private Const MCI_STATUS_NUMBER_OF_TRACKS = &H3&
Private Const MCI_STATUS_POSITION = &H2&
Private Const MCI_TRACK = &H10&
Private Const MCI_STATUS = &H814
Private mciOpenParms As MCI_OPEN_PARMS
Private mciSetParms As MCI_SET_PARMS
Private mciStatusParms As MCI_STATUS_PARMS
Private Type TTrackInfo
Minutes As Long
Seconds As Long
Frames As Long
FrameOffset As Long
End Type
Private m_Error As Long
Private m_CID As String
Private m_Drive As String
Private m_DeviceID As Long
Private m_NTracks As Integer
Private m_Length As Long
Private m_Tracks() As TTrackInfo
Private Sub Class_Initialize()
m_CID = "Not Ready"
m_Drive = ""
m_Error = 0
m_DeviceID = -1
m_NTracks = 0
End Sub
Public Property Get DiscID() As String
DiscID = m_CID
End Property
Public Property Get ErrorCode() As Long
Error = m_Error
End Property
Public Sub Init(sDrive As String)
Dim p1 As Integer
m_Error = MMSYSERR_NOERROR
m_Drive = sDrive
If OpenCD Then
Call LoadCDInfo
CloseCD
End If
End Sub
Private Sub Class_Terminate()
If m_DeviceID <> -1 Then
CloseCD
End If
End Sub
Private Function OpenCD() As Boolean
Dim Scode As Long, wDeviceID As Long
OpenCD = False
mciOpenParms.lpstrDeviceType = "cdaudio"
mciOpenParms.lpstrElementName = m_Drive
Scode = mciSendCommand(0, MCI_OPEN, (MCI_OPEN_TYPE Or MCI_OPEN_ELEMENT), mciOpenParms)